import random

def generate_lottery_number():
    lottery_number = []
    for i in range(6):
        number = random.randint(1, 49)
        while number in lottery_number:
            number = random.randint(1, 49)
        lottery_number.append(number)
    return sorted(lottery_number)

def compare_lottery_numbers(user_numbers, lottery_number):
    matched_numbers = set(user_numbers) & set(lottery_number)
    if len(matched_numbers) == 6:
        return "一等奖"
    elif len(matched_numbers) == 5 and user_numbers[-1] == lottery_number[-1]:
        return "二等奖"
    elif len(matched_numbers) == 5:
        return "三等奖"
    elif len(matched_numbers) == 4 and user_numbers[-1] == lottery_number[-1]:
        return "四等奖"
    elif len(matched_numbers) == 3 and user_numbers[-1] == lottery_number[-1]:
        return "五等奖"
    elif len(matched_numbers) == 2 and user_numbers[-1] == lottery_number[-1]:
        return "六等奖"
    else:
        return "未中奖"

if __name__ == "__main__":
    lottery_number = generate_lottery_number()
    print("随机生成的彩票号码为：", lottery_number)

    user_numbers = input("请输入你的彩票号码（用逗号分隔）：").split(',')
    user_numbers = [int(num) for num in user_numbers]
    result = compare_lottery_numbers(user_numbers, lottery_number)
    print("你的彩票号码与随机生成的彩票号码匹配情况：", result)
